package org.moriraaca.google.interview;

public class SequenceSum {
	int [] a;
	
	public SequenceSum(int [] a) {
		this.a = a;
	}
	
	public int getBSeqSum(int n) {
		int sum = 0;
		
		for (int i = 0; i < n; i++) {
			sum += (n - 1 - i) * a[i];
		}
		
		return sum;
	}
	
	public int getB(int i) {
		int sum = 0;
		
		for (int j = 0; j < i; j++) {
			sum += a[j];
		}
		
		return sum;
	}
}
